<?PHP
include("registroPacientes/headern.php");

$sql="select a.cNombre+' '+a.cPaterno+' '+a.cMaterno as Paciente,a.curp,a.id_principal as id_g, b.id_principal as id_reg, b.nTipoPaciente as nTP
		FROM dat_generales a
inner join dat_registro b on (a.id_principal = b.id_generales)
where a.nStatus = 0 and a.id_sector = ".$_SESSION['idsector']." and a.id_unidad = ".$_SESSION['idunidad']." ";
/*
$sql .= " where nStatus = 0 ";

$sql="SELECT catalogos.dbo.fUnidad_proced(a.id_sector,a.id_unidad) as Unidad, 
		a.cNombre+' '+a.cPaterno+' '+a.cMaterno as Paciente,a.curp,a.id_principal as id_g, b.id_principal as id_reg
		FROM dat_generales a
inner join dat_registro b on (a.id_principal = b.id_generales)
where a.nStatus = 0";*/


	$qry=mssql_query($sql,$link) or die(mssql_get_last_message());
	$total=mssql_num_rows($qry);
	
?><style type="text/css">
<!--
.Estilo1 {font-weight: bold}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
<div id="inicio">
<table width='750' align='center' cellpadding='2' cellspacing='2'  border='0' class='cuadro2 datos'>
  <tr >
    <td height="25" colspan="6"  align="center" bgcolor='#FE8A01' class="nombres estilo1">
    <b>LISTA DE PACIENTES</b></td>
  </tr>
  <tr bgcolor='#CCCCCC'>
    <td class="datos"><strong>PACIENTE</strong></td>
	<td align="center"  class="datos"><strong>CURP</strong></td>
	<td align="center" class="datos"><strong>FECHA DE NACIMIENTO</strong></td>
    <td align="center" class="datos"><strong>CEDULA DEL PACIENTE</strong></td>        
  </tr>
<?php
while($datos = mssql_fetch_array($qry)){
	
	$fondo = ($fondo=='#f3f3f3'?'#FFFFFF':'#f3f3f3');
	echo "<tr bgcolor='$fondo'>";
	for($i=0;$i<=3;$i++){
		echo "<td class='datos'>";
		if ($i == 0) {
			$datos_ = "<a href='#' onclick='liga(\"registroPacientes/datos_generales.php?id_generales=$datos[id_g]&id_principal=$datos[id_reg]&nTipoPaciente=$datos[nTP]\",\"inicio\")'>".$datos[$i]."</a>";
		}
		else if($i==2){ 
		$fNac = $datos["nAnio"]."-".$datos["nMeses"]."-".$datos["nDias"];
			 $datos_ = formatofecha($fNac); 
		}
		else if($i==3){ 
	$datos_ = "<a href='imp_cedula.php?id_reg=".$datos["id_reg"]."&id_principal=".$datos["id_g"]."' target='_blank'>ver cedula</a>";
		}	
		else {
		$datos_ = $datos[$i];
		}
		echo $datos_;
		echo "</td>";
	}
	echo "</tr>";
}
?> 
</table>
</div>




